package com.nhxcz.bigdataweb.utils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author zhaohaitang
 */
@WebServlet("/verifycode")
public class VerifiyServlet extends HttpServlet {

    private static final long serialVersionUID = - 3985499022704307949L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String code0 = req.getParameter("Code");
        HttpSession session = req.getSession();
        String code1 = (String) session.getAttribute("Code");
        System.out.println(code0 + " " + code1);
        if (code0.equals(code1)) {
            resp.getOutputStream().print("yes");
        } else {
            resp.getOutputStream().print("no");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

}
